package com.oocl.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oocl.dto.FoodDTO;
import com.oocl.dto.MUserDTO;
import com.oocl.dto.MUserFoodListDTO;
import com.oocl.exception.MyException;
import com.oocl.service.FoodService;
import com.oocl.service.MuserService;
import com.oocl.service.impl.FoodServiceImpl;
import com.oocl.service.impl.MuserServiceImpl;
import com.oocl.util.RequestUtil;


public class MusersList2CServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		MuserService mSer = new MuserServiceImpl();
		String ftype = request.getParameter("type");
		if(null!=ftype){
			ftype = ftype.trim();
		}else{
			ftype = "";
		}
		System.out.println(ftype);
		List<MUserDTO> list = null;
		try {
			list = mSer.loadMusersDTOsByFtype(ftype);
			String json = RequestUtil.wrapToJson(list);
			System.out.println(json);
			response.setCharacterEncoding("utf-8");
			response.getWriter().write(json);
		} catch (MyException e) {
			throw e;
		}
	}

}
